<template>
  <div class="box">
    <div class="top">手机号注册</div>
    <div class="Return" @click="Return"></div>
    <div class="content">
      <div class="phone">
        <input type="text" placeholder="输入手机号" v-model="tel">
      </div>
      <div class="password">
        <input type="password"  placeholder="设置登录密码，不少于6位" v-model="password">
      </div>
      <div class="number">+86</div>
      <div class="login" @click="nextseup">下一步</div>

    </div>

      <v-other></v-other>

  </div>
</template>

<script>

  import other from  "@/components/other"
  export default {
    name:'register',
    data(){
      return{
        tel:'',
        password:''
      }
    },
    mounted(){
    },
    methods: {
      Return(){
        this.$router.push({ name: 'login' });
      },
      nextseup(){
        if(this.tel.length!==11){
          this.$toast('请输入正确的手机号');
          return
        }
        if(this.password.length<6){
          this.$toast('登录密码不能少于6位');
          return
        }
        this.$http.get(`/api/cellphone/existence/check?phone=${this.tel}`)
          .then((res)=>{
            if(res.data.hasPassword){
              this.$toast('该手机号已注册')
            }else {
              this.$http.get(`/api/captcha/sent?phone=${this.tel}`)
                .then((res)=>{
                  this.$router.push({path:'/sms',query:{tel:this.tel,pwd:this.password}});
                })

            }
          })
      }

    },
    components:{
      "v-other" :other,
    }
  }

</script>

<style scoped>
  .box{
    width: 100vw;
    height: 100vh;
  }
  .top{
    width: 100vw;
    height: 50px;
    line-height: 50px;
    text-align: center;
    font-size: 18px;
    color: #fffdef;
    background: #C64B3D url("../assets/login-register/cancel.png") no-repeat 20px 12px;
    background-size: 14px;
    position: relative;
  }
  .content{
    width: 100vw;
    height: 400px;
    margin-top: 20px;
    position: relative;
  }
  .phone,.password{
    width: 90vw;
    height: 40px;
    margin: 0 auto;
    border-bottom: 2px solid #F2F3F4;
  }
  .phone{
    background: url("../assets/login-register/phone.png") no-repeat 5px 10px;
    background-size: 14px;
  }
  .password{
    background: url("../assets/login-register/lock.png") no-repeat 5px 10px;
    background-size: 14px;
  }
  .phone input,.password input{
    width: 80vw;
    height: 30px;
    display: block;
    outline:medium;
    font-size: 16px;
    border: none;
    margin-top: 5px;
    padding-top: 5px;
    margin-left: 35px;

  }
  .phone input{
    width: 70vw;
    margin-left: 75px;
  }
  .password{
    width: 90vw;
    height: 40px;
    margin: 0 auto;
  }
  .login{
    width: 90vw;
    height: 40px;
    border-radius: 45px;
    margin: 30px auto ;
    line-height: 40px;
    text-align: center;
    background: -webkit-linear-gradient(left, #E75D4C ,#C3473A);
    font-size: 18px;
    color: #e79482;
  }
  .number{
    width: 35px;
    height: 20px;
    font-weight: bold;
    font-size: 20px;
    position: absolute;
    top: 7px;
    left: 44px;
    color: #383839;
  }
  .Return {
    width: 25px;
    height: 30px;
    position: absolute;
    top: 10px;
    left: 18px;
  }


</style>
